home *** CD-ROM | disk | FTP | other *** search
/ Shareware Extravaganza - Disc 4 / Shareware Extravaganza - Over 25,000 Programs (The Ultimate Shareware Company)(Disc 4 of 4)(1993).iso / cad / chtext.zip / CHTEXT.LSP
Lisp/Scheme  |  1990-09-27  |  23KB  |  743 lines

  1. ;;;   CHTEXT.lsp
  2. ;;;   Copyright (C) 1990 by Autodesk, Inc.
  3. ;;;  
  4. ;;;   Permission to use, copy, modify, and distribute this software and its
  5. ;;;   documentation for any purpose and without fee is hereby granted.  
  6. ;;;
  7. ;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. 
  8. ;;;   ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF 
  9. ;;;   MERCHANTABILITY ARE HEREBY DISCLAIMED.
  10. ;;; 
  11. ;;;   by Jan S. Yoder
  12. ;;;   09 March  1990 
  13. ;;; 
  14. ;;;--------------------------------------------------------------------------;
  15. ;;; DESCRIPTION
  16. ;;;   This is a "text processor" which operates in a global manner 
  17. ;;;   on all of the text entities that the user selects; i.e., the
  18. ;;;   Height, Justification, Location, Rotation, Style, Text, and
  19. ;;;   Width can all be changed globally or individually, and the
  20. ;;;   range of values for a given parameter can be listed.
  21. ;;;   
  22. ;;;   The command is called with CHT from the command line at which
  23. ;;;   time the user is asked to select the objects to change.
  24. ;;;   
  25. ;;;     Select text to change. 
  26. ;;;     Select objects:
  27. ;;;  
  28. ;;;   If nothing is selected the message "ERROR: Nothing selected." 
  29. ;;;   is displayed and the command is terminated.  If more than 25
  30. ;;;   entities are selected the following message is displayed while
  31. ;;;   the text entities are sorted out from the non-text entities.
  32. ;;;   A count of the text entities found is then displayed.
  33. ;;;   
  34. ;;;     Verifying the selected entities -- please wait.
  35. ;;;     nnn  text entities found.
  36. ;;;     CHText:  Height/Justification/Location/Rotation/Style/Text/Undo/Width:
  37. ;;;   
  38. ;;;   A typical example of the prompts you may encounter follows:
  39. ;;;   
  40. ;;;   If you select a single text entity to change and ask to change
  41. ;;;   the height, the prompt looks like this:
  42. ;;;   
  43. ;;;     CHText:  Height/Justification/Location/Rotation/Style/Text/Undo/Width:
  44. ;;;     New text height for text entity. <0.08750000>:
  45. ;;;   
  46. ;;;   If you select more than one text entity to change and ask to change
  47. ;;;   the height, the prompt looks like this:
  48. ;;;   
  49. ;;;     CHText:  Height/Justification/Location/Rotation/Style/Text/Undo/Width:
  50. ;;;     Individual/List/<New height for all entities>:
  51. ;;;   
  52. ;;;   Typing "L" at this prompt returns a prompt showing you the range of
  53. ;;;   values that you are using for your text.
  54. ;;;   
  55. ;;;     Height -- Min: 0.05000000  Max: 0.10000000  Ave: 0.08392857
  56. ;;;   
  57. ;;;   Typing "I" at this prompt puts you in a loop, processing the text
  58. ;;;   entities you have selected one at a time, and giving the same prompt
  59. ;;;   you get for a single text entity shown above.
  60. ;;;   
  61. ;;;   Pressing RETURN at this point puts you back at the Command: prompt.
  62. ;;;   Selecting any of the other options allows you to change the text
  63. ;;;   entities selected. 
  64. ;;;   
  65. ;;;   All of the Release 11 text alignment options have been supported.  
  66. ;;;   This is based on the system variable "DIMCLRD" being present.  
  67. ;;;   If it is not present, then only the  Release 10 alignment options 
  68. ;;;   are allowed.
  69. ;;;   
  70. ;;;---------------------------------------------------------------------------;
  71. ;;;
  72. ;;; Main function -- no arguments
  73. ;;;
  74. (defun chtxt (/ sset opt ssl nsset temp unctr 
  75.                 sslen style hgt rot txt ent cht_oc
  76.                 loc loc1 justp justq orthom )
  77.  
  78.   (setq pt_ver "1.00")                ; Reset this local if you make a change.
  79.   ;;
  80.   ;; Internal error handler defined locally
  81.   ;;
  82.   (defun cht_er (s)                   ; If an error (such as CTRL-C) occurs
  83.                                       ; while this command is active...
  84.     (if (/= s "Function cancelled")
  85.       (if (= s "quit / exit abort")
  86.         (princ)
  87.         (princ (strcat "\nError: " s))
  88.       )
  89.     )
  90.     (eval(read U:E))
  91.     (if cht_oe                        ; If an old error routine exists
  92.       (setq *error* cht_oe)           ; then, reset it 
  93.     )
  94.     (if cht_oc (setvar "cmdecho" cht_oc)) ; Reset command echoing
  95.     (if cht_ot (setvar "texteval" cht_ot)) 
  96.     (if cht_oh (setvar "highlight" cht_oh)) 
  97.     (princ)
  98.   )
  99.   ;;
  100.   ;; Body of function
  101.   ;;
  102.   (if *error*                         ; Set our new error handler
  103.     (setq cht_oe *error* *error* cht_er) 
  104.     (setq *error* cht_er) 
  105.   )
  106.  
  107.   ;; Set undo groups and ends with (eval(read U:G)) or (eval(read U:E))
  108.   (setq U:G "(command \"undo\" \"group\")"
  109.         U:E "(command \"undo\" \"end\")"
  110.   )
  111.   
  112.   (setq cht_oc (getvar "cmdecho"))
  113.   (setq cht_oh (getvar "highlight")) 
  114.   (setvar "cmdecho" 0)
  115.   
  116.   (eval(read U:G))
  117.  
  118.   (princ (strcat "\nChange text, Version " pt_ver 
  119.                  ", (c) 1990 by Autodesk, Inc. "))
  120.   (prompt "\nSelect text to change. ")
  121.   (setq sset (ssget))
  122.   (if (null sset) 
  123.     (progn
  124.       (princ "\nERROR: Nothing selected.")
  125.       (exit)
  126.     )
  127.   )
  128.   ;; Verify the entity set.
  129.   (cht_ve)
  130.   ;; This is the main option loop.
  131.   (cht_ol)
  132.  
  133.   (if cht_oe (setq *error* cht_oe))   ; Reset old error function if error
  134.   (eval(read U:E))
  135.   (if cht_ot (setvar "texteval" cht_ot)) 
  136.   (if cht_oh (setvar "highlight" cht_oh)) 
  137.   (if cht_oc (setvar "cmdecho" cht_oc)) ; Reset command echoing
  138.   (princ)
  139. )
  140. ;;;
  141. ;;; Verify and sort out non-text entities from the selection set.
  142. ;;;
  143. (defun cht_ve ()
  144.   (setq ssl   (sslength sset)
  145.         nsset (ssadd))
  146.   (if (> ssl 25)
  147.     (princ "\nVerifying the selected entities -- please wait. ")
  148.   )
  149.   (while (> ssl 0)
  150.     (setq temp (ssname sset (setq ssl (1- ssl))))
  151.     (if (= (cdr(assoc 0 (entget temp))) "TEXT")
  152.       (ssadd temp nsset)
  153.     )
  154.   )
  155.   (setq ssl (sslength nsset)
  156.         sset nsset
  157.         unctr 0
  158.   )
  159.   (print ssl)
  160.   (princ "text entities found. ")
  161. )
  162. ;;;
  163. ;;; The option loop.
  164. ;;;
  165. (defun cht_ol ()
  166.   (setq opt T)
  167.   (while (and opt (> ssl 0))
  168.     (setq unctr (1+ unctr))
  169.     (command "undo" "group")
  170.     (initget "Location Justification Style Height Rotation Width Text Undo")
  171.     (setq opt (getkword 
  172.       "\nHeight/Justification/Location/Rotation/Style/Text/Undo/Width: "))
  173.     (if opt
  174.       (cond
  175.         ((= opt "Undo")
  176.           (cht_ue)                    ; Undo the previous command.
  177.         )
  178.         ((= opt "Location")
  179.           (cht_le)                    ; Change the location.
  180.         )
  181.         ((= opt "Justification")
  182.           (cht_je)                    ; Change the justification.
  183.         )
  184.         ((= opt "Style")    (cht_pe "Style"    "style name"      7) )
  185.         ((= opt "Height")   (cht_pe "Height"   "height"         40) )
  186.         ((= opt "Rotation") (cht_pe "Rotation" "rotation angle" 50) )
  187.         ((= opt "Width")    (cht_pe "Width"    "width factor"   41) )
  188.         ((= opt "Text")
  189.           (cht_te)                    ; Change the text.
  190.         )
  191.       )
  192.       (setq opt nil)
  193.     )
  194.     (command "undo" "end")
  195.   )
  196. )
  197. ;;;
  198. ;;; Undo an entry.
  199. ;;;
  200. (defun cht_ue ()
  201.   (if (> unctr 1)
  202.     (progn
  203.       (command "undo" "end")
  204.       (command "undo" "2")
  205.       (setq unctr (- unctr 2))
  206.     )
  207.     (progn
  208.       (princ "\nNothing to undo. ")
  209.       (setq unctr (- unctr 1))
  210.     )
  211.   )
  212. )
  213. ;;;
  214. ;;; Change the location of an entry.
  215. ;;;
  216. (defun cht_le ()
  217.   (setq sslen (sslength sset)
  218.         style ""
  219.         hgt   ""
  220.         rot   ""
  221.         txt   ""
  222.   )
  223.   (command "change" sset "" "")
  224.   (while (> sslen 0)
  225.     (setq ent (entget(ssname sset (setq sslen (1- sslen))))
  226.           opt (list (cadr (assoc 11 ent))
  227.                     (caddr (assoc 11 ent))
  228.                     (cadddr (assoc 11 ent)))
  229.     )
  230.     (prompt "\nNew text location: ")
  231.     (command pause)
  232.     (if (null loc)
  233.       (setq loc opt)
  234.     )
  235.     (command style hgt rot txt)
  236.   )
  237.   (command)
  238. )
  239. ;;;
  240. ;;; Change the justification of an entry.
  241. ;;;
  242. (defun cht_je ()
  243.   (if (getvar "DIMCLRD")
  244.     (initget (strcat "TLeft TCenter TRight "
  245.                      "MLeft MCenter Mright "
  246.                      "BLeft BCenter Bright "
  247.                      "Aligned Center Fit Left Middle Right ?"))
  248.     (initget "Aligned Center Fit Left Middle Right ?")
  249.   )
  250.   (setq sslen (sslength sset))
  251.   (setq justp (getkword (strcat "\nJustification point(s) - "
  252.               "Aligned/Center/Fit/Left/Middle/Right/<?>: ")))
  253.   (cond
  254.     ((= justp "Left")    (setq justp 0 justq 0) )
  255.     ((= justp "Center")  (setq justp 1 justq 0) )
  256.     ((= justp "Right")   (setq justp 2 justq 0) )
  257.     ((= justp "Aligned") (setq justp 3 justq 0) )
  258.     ((= justp "Fit")     (setq justp 5 justq 0) )
  259.     ((= justp "TLeft")   (setq justp 0 justq 3) )
  260.     ((= justp "TCenter") (setq justp 1 justq 3) )
  261.     ((= justp "TRight")  (setq justp 2 justq 3) )
  262.     ((= justp "MLeft")   (setq justp 0 justq 2) )
  263.     ((= justp "Middle")  (setq justp 1 justq 2) )
  264.     ((= justp "MCenter") (setq justp 1 justq 2) )
  265.     ((= justp "MRight")  (setq justp 2 justq 2) )
  266.     ((= justp "BLeft")   (setq justp 0 justq 1) )
  267.     ((= justp "BCenter") (setq justp 1 justq 1) )
  268.     ((= justp "BRight")  (setq justp 2 justq 1) )
  269.     ((= justp "?")       (setq justp nil)       )
  270.     (T                   (setq justp nil)       )
  271.   )   
  272.   (if justp
  273.     (justpt) ; Process them...
  274.     (justpn) ; List options...
  275.   )
  276.   (command)
  277. )
  278. ;;;
  279. ;;; Get alignment points for "aligned" or "fit" text.
  280. ;;;
  281. (defun justpt ()
  282.   (while (> sslen 0)
  283.     (setq ent (entget(ssname sset (setq sslen (1- sslen))))
  284.           ent (subst (cons 72 justp) (assoc 72 ent) ent)
  285.           opt (trans (list (cadr (assoc 11 ent))
  286.                            (caddr (assoc 11 ent))
  287.                            (cadddr (assoc 11 ent))) 
  288.                      (cdr(assoc -1 ent)) ; from ECS
  289.                      1)               ; to current UCS
  290.     )
  291.     (if (getvar "DIMCLRD")
  292.       (setq ent (subst (cons 73 justq) (assoc 73 ent) ent))
  293.     )
  294.     (cond
  295.       ((or (= justp 3) (= justp 5))
  296.         (prompt "\nNew text alignment points: ")
  297.         (if (= (setq orthom (getvar "orthomode")) 1)
  298.           (setvar "orthomode" 0)
  299.         )
  300.         (redraw (cdr(assoc -1 ent)) 3)
  301.         (initget 1)
  302.         (setq loc (getpoint))
  303.         (initget 1)
  304.         (setq loc1 (getpoint loc))
  305.         (redraw (cdr(assoc -1 ent)) 1)
  306.         (setvar "orthomode" orthom)
  307.         (setq ent (subst (cons 10 loc) (assoc 10 ent) ent))
  308.         (setq ent (subst (cons 11 loc1) (assoc 11 ent) ent))
  309.       )
  310.       ((/= justp 0)
  311.         (redraw (cdr(assoc -1 ent)) 3)
  312.         (prompt "\nNew text location: ")
  313.         (if (= (setq orthom (getvar "orthomode")) 1)
  314.           (setvar "orthomode" 0)
  315.         )
  316.         (setq loc (getpoint opt))
  317.         (setvar "orthomode" orthom)
  318.         (redraw (cdr(assoc -1 ent)) 1)
  319.         (if (null loc)
  320.           (setq loc opt)
  321.           (setq loc (trans loc 1 (cdr(assoc -1 ent))))
  322.         )
  323.         (setq ent (subst (cons 11 loc) (assoc 11 ent) ent))
  324.       )
  325.     )
  326.     (entmod ent)
  327.   )
  328. )
  329. ;;;
  330. ;;; List the options.
  331. ;;;
  332. (defun justpn ()
  333.   (if (getvar "DIMCLRD") (textpage))
  334.   (princ "\nAlignment options: ")
  335.   (princ "\n\t TLeft   TCenter   TRight ")
  336.   (princ "\n\t MLeft   MCenter   MRight ")
  337.   (princ "\n\t BLeft   BCenter   BRight ")
  338.   (princ "\n\t  Left    Center    Right")
  339.   (princ "\n\tAligned   Middle    Fit")
  340.   (if (not (getvar "DIMCLRD")) (textscr))
  341.   (princ "\n\nPress any key to return to your drawing. ")
  342.   (grread)
  343.   (princ "\r                                           ")
  344.   (graphscr)
  345. )
  346. ;;;
  347. ;;; Change the text of an entity.
  348. ;;;
  349. (defun cht_te ()
  350.   (setq sslen (sslength sset))
  351.   (initget "Globally Individually Retype")
  352.   (setq ans (getkword 
  353.     "\nSearch and replace text.  Individually/Retype/<Globally>:"))
  354.   (setq cht_ot (getvar "texteval"))
  355.   (setvar "texteval" 1)
  356.   (cond 
  357.     ((= ans "Individually")
  358.       (if (= (getvar "popups") 1)
  359.         (progn
  360.           (initget "Yes No")
  361.           (setq ans (getkword "\nEdit text in dialogue? <Yes>:"))
  362.         )
  363.         (setq ans "No")
  364.       )
  365.   
  366.       (while (> sslen 0)
  367.         (redraw (setq sn (ssname sset (setq sslen (1- sslen)))) 3)
  368.         (setq ss (ssadd))
  369.         (ssadd (ssname sset sslen) ss)
  370.         (if (= ans "No") 
  371.           (chgtext ss)
  372.           (command "ddedit" sn "")
  373.         )
  374.         (redraw sn 1)
  375.       )
  376.     )
  377.     ((= ans "Retype")
  378.       (while (> sslen 0)
  379.         (setq ent (entget(ssname sset (setq sslen (1- sslen)))))
  380.         (redraw (cdr(assoc -1 ent)) 3)
  381.         (prompt (strcat "\nOld text: " (cdr(assoc 1 ent))))
  382.         (setq nt (getstring  T "\nNew text: "))
  383.         (redraw (cdr(assoc -1 ent)) 1)
  384.         (if (> (strlen nt) 0)
  385.           (entmod (subst (cons 1 nt) (assoc 1 ent) ent))
  386.         )
  387.       )
  388.     )
  389.     (T
  390.       (chgtext sset)                  ; Change 'em all
  391.     )
  392.   )
  393.   (setvar "texteval" cht_ot)
  394. )
  395. ;;;
  396. ;;; The old CHGTEXT command - rudimentary text editor
  397. ;;;
  398. ;;;
  399. (defun C:CHGTEXT () (chgtext nil))
  400.  
  401. (defun chgtext (objs / last_o tot_o ent o_str n_str st s_temp 
  402.                        n_slen o_slen si chf chm cont ans)
  403.   (if (null objs)
  404.     (setq objs (ssget))               ; Select objects if running standalone
  405.   )
  406.   (setq chm 0)
  407.   (if objs 
  408.     (progn                   ; If any objects selected
  409.       (if (= (type objs) 'ENAME) 
  410.         (progn
  411.           (setq ent (entget objs))
  412.           (princ (strcat "\nExisting string: " (cdr (assoc 1 ent))))
  413.         )
  414.         (if (= (sslength objs) 1)
  415.           (progn
  416.             (setq ent (entget (ssname objs 0)))
  417.             (princ (strcat "\nExisting string: " (cdr (assoc 1 ent))))
  418.           )
  419.         )
  420.       )
  421.       (setq o_str (getstring "\nMatch string   : " t))
  422.       (setq o_slen (strlen o_str))
  423.       (if (/= o_slen 0)
  424.         (progn
  425.           (setq n_str (getstring "\nNew string     : " t))
  426.           (setq n_slen (strlen n_str))
  427.           (setq last_o 0 
  428.                 tot_o  (if (= (type objs) 'ENAME)
  429.                          1
  430.                          (sslength objs)
  431.                        )
  432.           )
  433.           (while (< last_o tot_o)     ; For each selected object...
  434.             (if (= "TEXT"             ; Look for TEXT entity type (group 0)
  435.                    (cdr (assoc 0 (setq ent (entget (ssname objs last_o))))))
  436.               (progn
  437.                 (setq chf nil si 1)
  438.                 (setq s_temp (cdr (assoc 1 ent)))
  439.                 (while (= o_slen (strlen (setq st (substr s_temp si o_slen))))
  440.                   (if (= st o_str)
  441.                     (progn
  442.                       (setq s_temp (strcat 
  443.                                      (if (> si 1)
  444.                                        (substr s_temp 1 (1- si)) 
  445.                                        ""
  446.                                      )
  447.                                      n_str
  448.                                      (substr s_temp (+ si o_slen))
  449.                                    )
  450.                       )
  451.                       (setq chf t)    ; Found old string
  452.                       (setq si (+ si n_slen))
  453.                     )
  454.                     (setq si (1+ si))
  455.                   )
  456.                 )
  457.                 (if chf 
  458.                   (progn              ; Substitute new string for old
  459.                     ; Modify the TEXT entity
  460.                     (entmod (subst (cons 1 s_temp) (assoc 1 ent) ent))
  461.                     (setq chm (1+ chm))
  462.                   )
  463.                 )
  464.               )
  465.             )
  466.             (setq last_o (1+ last_o))
  467.           )
  468.         )
  469.         ;; else go on to the next line...
  470.       )
  471.     )
  472.   )
  473.   (if (/= (type objs) 'ENAME)
  474.     (if (/= (sslength objs) 1)        ; Print total lines changed
  475.       (princ (strcat "Changed "
  476.                      (rtos chm 2 0)
  477.                      " text lines."
  478.              )
  479.       )
  480.     )
  481.   )
  482.   (terpri)
  483. )
  484. ;;;
  485. ;;; Main procedure for manipulating text entities
  486. ;;; ARGUMENTS:
  487. ;;;   typ   -- Type of operation to perform
  488. ;;;   prmpt -- Partial prompt string to insert in standard prompt line
  489. ;;;   fld   -- Assoc field to be changed
  490. ;;; GLOBALS:
  491. ;;;   sset  -- The selection set of text entities
  492. ;;;
  493. (defun cht_pe (typ prmpt fld / temp ow nw ent tw sty w hw lw 
  494.                               sslen n sn ssl)
  495.   (if (= (sslength sset) 1)           ; Special case if there is only
  496.                                       ; one entity selected
  497.     ;; Process one entity.
  498.     (cht_p1)
  499.     ;; Else
  500.     (progn
  501.       ;; Set prompt string.
  502.       (cht_sp)
  503.       (if (= nw "List")
  504.         ;; Process List request.
  505.         (cht_pl)
  506.         (if (= nw "Individual")
  507.           ;; Process Individual request.
  508.           (cht_pi)
  509.           (if (= nw "Select")
  510.             ;; Process Select request.
  511.             (cht_ps)
  512.             ;; Else
  513.             (progn
  514.               (if (= typ "Rotation")
  515.                 (setq nw (* (/ nw 180.0) pi))
  516.               )
  517.               (if (= (type nw) 'STR)
  518.                 (if (not (tblsearch "style" nw))
  519.                   (progn
  520.                     (princ (strcat "\nStyle " nw " not found. "))
  521.                   )
  522.                   (cht_pa)
  523.                 )
  524.                 (cht_pa)
  525.               )
  526.             )
  527.           )
  528.         )
  529.       )
  530.     )
  531.   )
  532. )
  533. ;;;
  534. ;;; Change all of the entities in the selection set.
  535. ;;;
  536. (defun cht_pa ()
  537.   (setq sslen (sslength sset))
  538.   (setq cht_oh (getvar "texteval"))
  539.   (setvar "highlight" 0)
  540.   (while (> sslen 0)
  541.     (setq temp (ssname sset (setq sslen (1- sslen))))
  542.     (entmod (subst (cons fld nw)
  543.                    (assoc fld (setq ent (entget temp)))
  544.                    ent
  545.             )
  546.     )
  547.     
  548.   )
  549.   (setvar "highlight" cht_oh)
  550. )
  551. ;;;
  552. ;;; Change one text entity.
  553. ;;;
  554. (defun cht_p1 ()
  555.   (setq temp (ssname sset 0))
  556.   (setq ow (cdr(assoc fld (entget temp))))
  557.   (if (= opt "Rotation")
  558.     (setq ow (/ (* ow 180.0) pi))
  559.   )
  560.   (redraw (cdr(assoc -1 (entget temp))) 3)
  561.   (initget 0)
  562.   (if (= opt "Style")
  563.     (setq nw (getstring (strcat "\nNew " prmpt ". <"
  564.                               ow ">: ")))
  565.     (setq nw (getreal (strcat "\nNew " prmpt ". <"
  566.                               (rtos ow 2) ">: ")))
  567.   )
  568.   (if (or (= nw "") (= nw nil))
  569.     (setq nw ow)
  570.   )
  571.   (redraw (cdr(assoc -1 (entget temp))) 1)
  572.   (if (= opt "Rotation")
  573.     (setq nw (* (/ nw 180.0) pi))
  574.   )
  575.   (if (= opt "Style")
  576.     (if (null (tblsearch "style" nw))
  577.       (princ (strcat "\nStyle " nw " not found. "))
  578.       
  579.       (entmod (subst (cons fld nw)
  580.                      (assoc fld (setq ent (entget temp)))
  581.                      ent
  582.               )
  583.       )
  584.     )
  585.     (entmod (subst (cons fld nw)
  586.                    (assoc fld (setq ent (entget temp)))
  587.                    ent
  588.             )
  589.     )
  590.   )
  591. )
  592. ;;;
  593. ;;; Set the prompt string.
  594. ;;;
  595. (defun cht_sp ()
  596.   (if (= typ "Style")
  597.     (progn
  598.       (initget "Individual List New Select ")
  599.       (setq nw (getkword (strcat "\nIndividual/List/Select style/<New "
  600.                                  prmpt
  601.                                  " for all text entities>: ")))
  602.       (if (or (= nw "") (= nw nil) (= nw "Enter"))
  603.         (setq nw (getstring (strcat "\nNew "
  604.                                     prmpt
  605.                                     " for all text entities: ")))
  606.       )
  607.     )
  608.     (progn
  609.       (initget "List Individual" 1)
  610.       (setq nw (getreal (strcat "\nIndividual/List/<New "
  611.                                  prmpt
  612.                                  " for all text entities>: ")))
  613.     )
  614.   )
  615. )
  616. ;;;
  617. ;;; Process List request.
  618. ;;;
  619. (defun cht_pl ()
  620.   (setq unctr (1- unctr))
  621.   (setq sslen (sslength sset))
  622.   (setq tw 0)
  623.   (while (> sslen 0)
  624.     (setq temp (ssname sset (setq sslen (1- sslen))))
  625.     (if (= typ "Style")
  626.       (progn
  627.         (if (= tw 0)
  628.           (setq tw (list (cdr(assoc fld (entget temp)))))
  629.           (progn
  630.             (setq sty (cdr(assoc fld (entget temp))))
  631.             (if (not (member sty tw))
  632.               (setq tw (append tw (list sty)))
  633.             )
  634.           )
  635.         )
  636.       )
  637.       (progn
  638.         (setq tw (+ tw (setq w (cdr(assoc fld (entget temp))))))
  639.         (if (= (sslength sset) (1+ sslen)) (setq lw w hw w))
  640.         (if (< hw w) (setq hw w))
  641.         (if (> lw w) (setq lw w))
  642.       )
  643.     )
  644.   )
  645.   (if (= typ "Rotation")
  646.     (setq tw (* (/ tw pi) 180.0)
  647.           lw (* (/ lw pi) 180.0)
  648.           hw (* (/ hw pi) 180.0))
  649.   )
  650.   (if (= typ "Style")
  651.     (progn
  652.       (princ (strcat "\n"
  653.                      typ
  654.                      "(s) -- "))
  655.       (princ tw)
  656.     )
  657.     (princ (strcat "\n"
  658.                      typ
  659.                      " -- Min: "
  660.                      (rtos lw 2)
  661.                      "\t Max: "
  662.                      (rtos hw 2)
  663.                      "\t Avg: "
  664.                      (rtos (/ tw (sslength sset)) 2) ))
  665.   )
  666. )
  667. ;;;
  668. ;;; Process Individual request.
  669. ;;;
  670. (defun cht_pi ()
  671.   (setq sslen (sslength sset))
  672.   (while (> sslen 0)
  673.     (setq temp (ssname sset (setq sslen (1- sslen))))
  674.     (setq ow (cdr(assoc fld (entget temp))))
  675.     (if (= typ "Rotation")
  676.       (setq ow (/ (* ow 180.0) pi))
  677.     )
  678.     (initget 0)
  679.     (redraw (cdr(assoc -1 (entget temp))) 3)
  680.     (if (= typ "Style")
  681.       (progn
  682.         (setq nw (getstring (strcat "\nNew "
  683.                                    prmpt
  684.                                    ". <"
  685.                                    ow ">: ")))
  686.       )
  687.       (progn
  688.         (setq nw (getreal (strcat "\nNew "
  689.                                    prmpt
  690.                                    ". <"
  691.                                 (rtos ow 2) ">: ")))
  692.       )
  693.     )
  694.     (if (or (= nw "") (= nw nil))
  695.       (setq nw ow)
  696.     )
  697.     (if (= typ "Rotation")
  698.       (setq nw (* (/ nw 180.0) pi))
  699.     )
  700.     (entmod (subst (cons fld nw)
  701.                    (assoc fld (setq ent (entget temp)))
  702.                    ent
  703.             )
  704.     )
  705.     (redraw (cdr(assoc -1 (entget temp))) 1)
  706.   )
  707. )
  708. ;;;
  709. ;;; Process the Select option.
  710. ;;;
  711. (defun cht_ps ()
  712.   (princ "\nSearch for which Style name?  <*>: ")
  713.   (setq sn  (strcase (getstring))
  714.         n   -1
  715.         sset nsset
  716.         nsset (ssadd)
  717.         ssl (1- (sslength sset))
  718.         )
  719.   (if (or (= sn "*") (null sn) (= sn ""))
  720.     (setq nsset sset sn "*")
  721.     (while (and sn (< n ssl))
  722.       (setq temp (ssname sset (setq n (1+ n))))
  723.       (if (= (cdr(assoc 7 (entget temp))) sn)
  724.         (ssadd temp nsset)
  725.       )
  726.     )
  727.   )
  728.   (setq ssl (sslength nsset))  
  729.   (princ "\nFound ")
  730.   (princ ssl)
  731.   (princ " text entities with STYLE of ")
  732.   (princ sn)
  733.   (princ ". ")
  734.   
  735.   (setq sset nsset)
  736. )
  737. ;;;
  738. ;;; The C: function definition.
  739. ;;;
  740. (defun c:cht    () (chtxt))
  741. (princ "\n\tc:CHText loaded.  Start command with CHT.")
  742. (princ)
  743.